@echo off
echo Starting HackPlay Platform Backend...

REM 检查虚拟环境是否存在
if not exist "venv" (
    echo Creating virtual environment...
    python -m venv venv
)

REM 激活虚拟环境
call venv\Scripts\activate

REM 安装依赖
echo Installing dependencies...
pip install -r requirements.txt

REM 检查环境配置文件
if not exist ".env" (
    echo Creating .env file from template...
    copy .env.example .env
    echo Please edit .env file with your configuration before running the server.
    pause
    exit /b 1
)

REM 运行数据库迁移
echo Running database migrations...
alembic upgrade head

REM 启动服务器
echo Starting FastAPI server...
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

pause